#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
typedef long long LL;
const int N = 1e3 + 10;
int tree[N];
int n;
int lowbit(int x)
{
	return x & -x;
}

void add(int x, int c)
{
	for (int i = x; i <= n; i += lowbit(i)) {
		tree[i] += c;
	}
}

int sum(int x)
{
	int res = 0;
	for (int i = x; i; i -= lowbit(i)) {
		res += tree[i];
	}
	return res;
}
int main()
{
	while (cin>>n) {
		int ans = 0;
		memset(tree, 0, sizeof(tree));
		for (int i = 1; i <= n; i++) {
			int a;
			scanf("%d", &a);
			ans += sum(n) - sum(a - 1);
			add(a, 1);
		}
		cout << ans << endl;
	}

	return 0;
}